{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Type hints help others (and future you) understand your code better."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20.0\n"
     ]
    }
   ],
   "source": [
    "def average(numbers: list[int]) -> float:\n",
    "    return sum(numbers) / len(numbers)\n",
    "\n",
    "\n",
    "print(average([10, 20, 30]))  # Output: 20.0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Type hints also help you write code that's more generic:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "20.0\n"
     ]
    }
   ],
   "source": [
    "from typing import Iterable\n",
    "\n",
    "\n",
    "def average(numbers: Iterable[int]) -> float:\n",
    "    return sum(numbers) / len(numbers)\n",
    "\n",
    "\n",
    "print(average((10, 20, 30)))  # Output: 20.0"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
